﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="r_elfutec_dados_gerais.aspx.cs" Inherits="relatorios_r_elfutec_dados_gerais" %>

<%    
    string Permissao_RelatoriosElfutec = "" + this.Session["Permissao_RelatoriosElfutec"];
    if (Permissao_RelatoriosElfutec != "1")
    {
        this.Response.Redirect("../login.aspx");
    }      
%>
<div style="background-color: White;">
    <%
        PL.DataBase.DAO.Instance.Setup(PL.DataBase.DatabaseTypes.MySql, PL.General.Instance.ElfutecConnectionString);
        PL.DataBase.DAO.Instance.Connector.Open();
        
        string nCourses = "0";        
        string sql = "SELECT Count(Id_Curso) AS Total FROM tb_Cursos WHERE Excluido=0";
        var reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nCourses = "" + reader["Total"];
        }
        reader.Close();

        string nPublicCourses = "0";
        sql = "SELECT COUNT(tb_Cursos.Id_Curso) AS Total FROM tb_Cursos INNER JOIN tb_AC ON (tb_Cursos.Id_Curso = tb_AC.Id_Curso) WHERE tb_Cursos.Excluido=0 AND tb_AC.Excluido=0";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nPublicCourses = "" + reader["Total"];
        }
        reader.Close();

        string nTexts = "0";
        sql = "SELECT COUNT(Id_Texto) AS Total FROM tb_textos WHERE Excluido=0";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nTexts = "" + reader["Total"];
        }
        reader.Close();    
        
        string nCaps = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_Capitulos WHERE Excluido=0  ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nCaps = "" + reader["Total"];
        }
        reader.Close();

        string nLic = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_Licao WHERE Excluido=0  ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nLic = "" + reader["Total"];
        }
        reader.Close();

                
        string nRed = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_redatores WHERE Excluido=0  ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nRed = "" + reader["Total"];
        }
        reader.Close();

        string nMat = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_Matriculas WHERE Excluido=0  ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nMat = "" + reader["Total"];
        }
        reader.Close();

        string nUsers = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_Usuarios WHERE Excluido=0  ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nUsers = "" + reader["Total"];
        }
        reader.Close();

        string nPags = "0";
        sql = "SELECT SUM(Acessos) AS Total FROM tb_AcessoPaginaCurso ";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nPags = "" + reader["Total"];
        }
        reader.Close();

        string nAmea = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_LogAmea";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nAmea = "" + reader["Total"];
        }
        reader.Close();
                
        string nTests = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_TestDef WHERE Excluido=0";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nTests = "" + reader["Total"];
        }
        reader.Close();

        string nQuests = "0";
        sql = "SELECT COUNT(*) AS Total FROM tb_QuestionsDef WHERE Excluido=0";
        reader = PL.DataBase.DAO.Instance.Connector.QueryWithReader(sql);
        if (reader.Read() == true)
        {
            nQuests = "" + reader["Total"];
        }
        reader.Close();                                                     
    %>
        <strong>Número de Cursos:</strong> <%= nCourses %> 
        <br />
        <strong>Número de Cursos Publicados:</strong> <%= nPublicCourses %> 
        <br />
        <strong>Número de Textos:</strong> <%= nTexts %> 
        <br />
        <strong>Número de Lições:</strong> <%= nLic%>
        <br />
        <strong>Número de Capítulos:</strong> <%= nCaps%>        
        <br />
        <strong>Número de Redatores:</strong> <%= nRed %>
        <br />
        <strong>Número de Matrículas:</strong> <%= nMat%>
        <br />
        <strong>Acessos as Páginas dos Cursos:</strong> <%= nPags%>
        <br />
        <strong>Acessos ao AMEA:</strong> <%= nAmea%>
        <br />
        <strong>Número de Avaliações:</strong> <%= nTests%>
        <br />
        <strong>Número de Questões:</strong> <%= nQuests%>
    <%
        PL.DataBase.DAO.Instance.Connector.Close();
    %>
</div>